home *** CD-ROM | disk | FTP | other *** search
- .IF DEFINED DOCUMENTATION
- ; ***************************************************************************
- .MODULE insert
- .LIBRARY csub
- .TYPE function
- .APPLICATION string
- .SYSTEM msdos-s
- .SYSTEM msdos-l
- .SYSTEM vms
- .SYSTEM unix
- .AUTHOR Software Toolz
- .LANGUAGE VAX-11 Assembly
- .DESCRIPTION
- Insertion of one string into another
- .ARGUMENTS
- char *insert(pattern,str,pos)
- char *pattern, /* (r) the characters to insert */
- *str; /* (r/w) the destination string */
- int pos; /* (r) the position at which to insert */
- .NARRATIVE
- Insert the "pattern" string into the destination string, "str", beginning
- at position, "pos", in the destination string.
- .RETURNS
- A pointer to your destination string.
- .REVISIONS 1/28/87
- Return pointer to destination string (rewritten in Assembly).
- .EXAMPLE
- char buff[128];
- strcpy(buff,"this test");
- insert("is a ",buff,5);
- .NOTICE
- Copyright 1989 Software Toolz, Inc. - Atlanta, Georgia
-
- All rights reserved worldwide. This program may not be reproduced,
- transmitted, transcribed, stored in a retrieval system or translated in
- any human or computer language, in any form without the express written
- permission of Software Toolz, Inc.
- .ENDOC END DOCUMENTATION
- ; ***************************************************************************
- .ENDC ; DOCUMENTATION
-
- .TITLE INSERT
- ; share a CODE PSECT with C functions
-
- .PSECT $CODE,PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT,NOVEC
-
- .ENTRY INSERT,^M<R2,R3,R4,R5>
-
- ADDL3 8(AP),12(AP),R2 ; calculate address of break
- PUSHL R2
- CALLS #1,G^STRLEN ; calculate length hi-part of string
- MOVL R0,R3 ; copy value for save
- INCL R3 ; add space for NULL
- PUSHL 4(AP) ; get pattern string length
- CALLS #1,G^STRLEN
- ADDL3 R0,R2,R4
- PUSHR #^M<R0,R2>
- MOVC3 R3,(R2),(R4) ; move hi-part up
- POPR #^M<R0,R2>
- MOVC3 R0,@4(AP),(R2) ; copy in the pattern string
- MOVL 8(AP),R0 ; copy string address for return
-
- RET
-
- .END ; stop assembly here
-